/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

/**
 *
 * @author Progresywny Maciek
 */

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import uk.co.caprica.vlcj.player.MediaPlayer;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.test.VlcjTest;
import uk.co.caprica.vlcj.test.thumbs.ThumbsTest;

/**
 * Test the various snapshot functions.
 * <p>
 * Note that you do <em>not</em> need the video to be displayed to capture
 * snapshots, see {@link ThumbsTest}.
 */
public class asd extends VlcjTest {

  public static void main(String[] args) throws Exception {
    System.setProperty("jna.library.path", "C:\\VLC"); 
    MediaPlayerFactory factory = new MediaPlayerFactory();
    MediaPlayer mediaPlayer = factory.newEmbeddedMediaPlayer();
   
    mediaPlayer.startMedia("rtsp://192.168.100.100:8086");
    
    Thread.sleep(10000); // Don't do this, use events instead
    
    BufferedImage image5 = mediaPlayer.getSnapshot();
    BufferedImage image6 = mediaPlayer.getSnapshot(300, 600);
    File outputfile = new File("D:\\saved.png");
    ImageIO.write(image5, "png", outputfile);
    mediaPlayer.stop();
  }
  
//  @SuppressWarnings("serial")
//  private static void show(String title, final BufferedImage img, int i) {
//    JFrame f = new JFrame(title);
//    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//    f.setContentPane(new JPanel() {
//      @Override
//      protected void paintChildren(Graphics g) {
//        Graphics2D g2 = (Graphics2D)g;
//        g2.drawImage(img, null, 0, 0);
//      }
//      @Override
//      public Dimension getPreferredSize() {
//        return new Dimension(img.getWidth(), img.getHeight());
//      }
//    });
//    f.pack();
//    f.setLocation(50 + (i * 50), 50 + (i * 50));
//    f.setVisible(true);
//  }
}
